import { createRouter, createWebHistory } from 'vue-router'
import Layui from "@/views/layout/index.vue"
import login from '@/views/login/index.vue'
import SubCategory from "@/views/SubCategory/index.vue"
import Detail from "@/views/detail/index.vue"
import Category from "@/views/category/index.vue"
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  // 路由滚动行为定制
  scrollBehavior(){
     return {
      top:0
     }
  },
  routes: [
    // 登录
    {
    path:"/login",
    name:"login",
    component:login,
    },
    {
      path: '/',
      name: 'home',
      component: Layui,
      children:[
        {
          path:"/",
          component:()=>import("@/views/home/index.vue")
        },
        {
          path:"category/:id",
          component: Category
        },
        // 二级面包屑
        {
          path:"/category/sub/:id",
          component:SubCategory
        },
        // 详情页
        {
          path: 'detail/:id',
          component: Detail
        },
        // 购物车页面
        {
          path:"/cartList",
          component:()=>import("@/views/CartList/index.vue")
        },
                // 购物车页面
    {
        path:"/checkout",
        component:()=>import("@/views/checkout/index.vue")
     },
    //  订单页
    {
      path:"/pay",
      component:()=>import("@/views/pay/index.vue")
    },
    // 支付成功
    {
      path:"/paycallback",
      component:()=>import("@/views/pay/payBack.vue")
    },
    // 会员
{
    path: '/member',
    name:"member",
    component:()=>import("@/views/Member/index.vue"),
    children: [
      {
        path: '',
        redirect:"/user"
      },
      {
        path: '/user',
        component:()=>import("@/views/Member/component/userInfo.vue")
      },
      {
        path: 'order',
        component:()=>import("@/views/Member/component/userOrder.vue")
      }
    ]
}
      ]
    },
  ]
})

export default router
